package com.example.spareparts.repository;

import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.*;
import com.example.spareparts.entity.InBoundRecords;
import java.util.List;

@Mapper
public interface InBoundRecordsRepository {
    @Select("SELECT * FROM InBoundRecords")
    List<InBoundRecords> findAllInBoundRecords();
    @Insert("INSERT INTO InBoundRecords (spare_part_id, quantity, batch_number, date,user_id) VALUES ( #{sparepartid}, #{quantity}, #{batchNumber}, #{date},#{userid})")
    @Options(useGeneratedKeys = true, keyProperty = "inboundid")
    void insertInBoundRecord(InBoundRecords inBoundRecord);
    @Update("UPDATE InBoundRecords SET inbound_id= #{inboundid}, spare_part_id= #{sparepartid}, quantity= #{quantity}, batch_number= #{batchNumber}, date= #{date} ,user_id= #{userid} WHERE inbound_id= #{inboundid}")
    void updateInBoundRecord(InBoundRecords inBoundRecord);
    @Delete("DELETE FROM InBoundRecords WHERE inbound_id= #{inboundid}")
    void deleteInBoundRecord(Long inboundid);
    @Select("SELECT * FROM InBoundRecords WHERE inbound_id= #{inboundid}")
    InBoundRecords findInBoundRecordById(Long inboundid);
    @Select("SELECT * FROM InBoundRecords WHERE spare_part_id= #{sparepartid}")
    List<InBoundRecords> findInBoundRecordBySparePartId(Long sparepartid);
    @Select("SELECT * FROM InBoundRecords WHERE batch_number= #{batchNumber}")
    InBoundRecords findInBoundRecordByBatchNumber(String batchNumber);

}
